package com.lx.dynamicdatasouce.mybatis.demo.service.impl;


import com.lx.dynamicdatasouce.mybatis.demo.entity.User;
import com.lx.dynamicdatasouce.mybatis.demo.mapper.r.RUserMapper;
import com.lx.dynamicdatasouce.mybatis.demo.mapper.w.WUserMapper;
import com.lx.dynamicdatasouce.mybatis.demo.service.IDemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author lX
 * @version JDK 8
 * @className DemoService (此处以class为例)
 * @date 2024/10/7
 * @description Demo实现类
 */
@Service
public class DemoService implements IDemoService {


    @Autowired
    private RUserMapper rUserMapper;

    @Autowired
    private WUserMapper wUserMapper;

    @Override
    public List<User> list() {
        return rUserMapper.list();
    }

    @Override
    public void saveW(User user) {
        user.setName("Wluoxue");
        wUserMapper.save(user);
    }

    @Override
    public void saveR(User user) {
        user.setName("Rluoxue");
        rUserMapper.save(user);

    }

    @Override
    public void save(User user) {
        user.setName("Wluoxue");
        wUserMapper.save(user);
    }
}

